package com.bstek;

import com.bstek.urule.runtime.KnowledgePackage;
import com.bstek.urule.runtime.KnowledgeSession;
import com.bstek.urule.runtime.KnowledgeSessionFactory;
import com.bstek.urule.runtime.response.FlowExecutionResponse;
import com.bstek.urule.runtime.response.RuleExecutionResponse;
import com.bstek.urule.runtime.service.KnowledgeService;
import com.pshtec.workshop.toc.model.CreditRiskControlResult;
import com.pshtec.workshop.toc.model.ScoreYXBaseResult;
import com.pshtec.workshop.toc.model.ScoreZJBaseResult;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@SpringBootApplication
public class EdasRuleClientApplication {
	public static void main(String[] args) throws IOException {
		ApplicationContext ctx = SpringApplication.run(EdasRuleClientApplication.class, args);
		
		//创建一个KnowledgeSession对象
    KnowledgeService knowledgeService = (KnowledgeService) ctx.getBean(KnowledgeService.BEAN_ID);
    KnowledgePackage knowledgePackage = knowledgeService.getKnowledge("运途金/1");
    KnowledgeSession session = KnowledgeSessionFactory.newKnowledgeSession(knowledgePackage);
		ScoreZJBaseResult scoreZJBaseResult = new ScoreZJBaseResult();
		scoreZJBaseResult.setScore(700);
		session.insert(scoreZJBaseResult);
		ScoreYXBaseResult scoreYXBaseResult = new ScoreYXBaseResult();
		scoreYXBaseResult.setScoreyxbase("800");
		session.insert(scoreYXBaseResult);
		CreditRiskControlResult controlResult = new CreditRiskControlResult();
		controlResult.setResult(true);
		session.insert(controlResult);
		FlowExecutionResponse response = session.startProcess("授信");
		System.out.println("result: ");
	}
}
